home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / newmat08.zip / NEWMAT9.CPP < prev    next >
C/C++ Source or Header  |  1995-01-15  |  1KB  |  60 lines

  1. //$$ newmat9.cpp         Input and output
  2.  
  3. // Copyright (C) 1991,2,3,4: R B Davies
  4.  
  5.  
  6. #define WANT_STREAM
  7.  
  8. #include "include.h"
  9.  
  10. #include "newmat.h"
  11. #include "newmatrc.h"
  12. #include "newmatio.h"
  13.  
  14. //#define REPORT { static ExeCounter ExeCount(__LINE__,9); ++ExeCount; }
  15.  
  16. #define REPORT {}
  17.  
  18. ostream& operator<<(ostream& s, const BaseMatrix& X)
  19. {
  20.    GeneralMatrix* gm = ((BaseMatrix&)X).Evaluate(); operator<<(s, *gm);
  21.    gm->tDelete(); return s;
  22. }
  23.  
  24.  
  25. ostream& operator<<(ostream& s, const GeneralMatrix& X)
  26. {
  27.    MatrixRow mr((GeneralMatrix*)&X, LoadOnEntry);
  28.    int w = s.width();  int nr = X.Nrows();  long f = s.flags();
  29.    s.setf(ios::fixed, ios::floatfield);
  30.    for (int i=1; i<=nr; i++)
  31.    {
  32.       int skip = mr.skip;  int storage = mr.storage;
  33.       Real* store = mr.store+skip;  skip *= w+1;
  34.       while (skip--) s << " ";
  35.       while (storage--) { s.width(w); s << *store++ << " "; }
  36. //      while (storage--) s << setw(w) << *store++ << " ";
  37.       mr.Next();  s << "\n";
  38.    }
  39.    s << flush;  s.flags(f); return s;
  40. }
  41.  
  42. // include this stuff if you are using an old version of G++
  43. // with an incomplete io library
  44.  
  45. /*
  46.  
  47. ostream& operator<<(ostream& os, Omanip_precision i)
  48.    { os.precision(i.x); return os; }
  49.  
  50. Omanip_precision setprecision(int i) { return Omanip_precision(i); }
  51.  
  52. ostream& operator<<(ostream& os, Omanip_width i)
  53.    { os.width(i.x); return os; }
  54.  
  55. Omanip_width setw(int i) { return Omanip_width(i); }
  56.  
  57. */
  58.  
  59.  
  60.